{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-header">
        <div class="layui-form toolbar">
            <div class="layui-form-item">
                <form action="{:request()->url()}" class="layui-form" method="get">
                <div class="layui-inline" style="padding-left: 0px;">
                    <a href="{:url('wechat/user/get_user')}" class="layui-btn layui-btn-warm"><i class="fa fa-star"></i> 更新会员</a>
                </div>
                
                
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">来源：</label>
                    <div class="layui-input-inline mr0">
                        <select name="subscribe_scene">
                            <option value="">请选择</option>
                            <option value="ADD_SCENE_SEARCH" {if condition="isset($data) and input('subscribe_scene') eq 'ADD_SCENE_SEARCH'"}selected="selected"{/if}>公众号搜索</option>
                            <option value="ADD_SCENE_ACCOUNT_MIGRATION" {if condition="isset($data) and input('subscribe_scene') eq 'ADD_SCENE_ACCOUNT_MIGRATION'"}selected="selected"{/if}>公众号迁移</option>
                            <option value="ADD_SCENE_PROFILE_CARD" {if condition="isset($data) and input('subscribe_scene') eq 'ADD_SCENE_PROFILE_CARD'"}selected="selected"{/if}>名片分享</option>
                            <option value="ADD_SCENE_QR_CODE" {if condition="isset($data) and input('subscribe_scene') eq 'ADD_SCENE_QR_CODE'"}selected="selected"{/if}>扫描二维码</option>
                            <option value="ADD_SCENE_PROFILE_LINK" {if condition="isset($data) and input('subscribe_scene') eq 'ADD_SCENE_PROFILE_LINK'"}selected="selected"{/if}>图文页内名称点击</option>
                            <option value="ADD_SCENE_PROFILE_ITEM" {if condition="isset($data) and input('subscribe_scene') eq 'ADD_SCENE_PROFILE_ITEM'"}selected="selected"{/if}>图文页右上角菜单</option>
                            <option value="ADD_SCENE_PAID" {if condition="isset($data) and input('subscribe_scene') eq 'ADD_SCENE_PAID'"}selected="selected"{/if}>支付后关注</option>
                            <option value="ADD_SCENE_OTHERS" {if condition="isset($data) and input('subscribe_scene') eq 'ADD_SCENE_OTHERS'"}selected="selected"{/if}>其他</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">状态：</label>
                    <div class="layui-input-inline mr0">
                        <select name="subscribe">
                            <option value="">请选择</option>
                            <option value="0" {if condition="isset($data) and input('subscribe') eq '0'"}selected="selected"{/if}>未关注</option>
                            <option value="1" {if condition="isset($data) and input('subscribe') eq '1'"}selected="selected"{/if}>已关注</option>
                        </select>
                    </div>
                </div>

                <div class="layui-inline" style="padding-left: 20px;">
                    <button class="layui-btn layui-btn-primary ajax-search"><i class="fa fa-search"></i> 搜索</button>
                </div>
                </form>
            </div>
        </div>
    </div>
    <table class="layui-table" id="tableTrack" lay-filter="tableTrack"></table>
    <!-- 表格状态列 -->
    <script type="text/html" id="demoEDStateBar1">
        {{# if(d.subscribe==0){ }}
        <button class="layui-btn layui-btn-xs layui-btn-primary">未关注</button>
        {{# }else if(d.subscribe==1){ }}
        <button class="layui-btn layui-btn-xs layui-btn-normal">已关注</button>
        {{# } }}
    </script>
</div>
{/block}
{block name="js"}
<script>
    layui.use(['layer', 'form', 'table', 'util', 'dropdown'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var admin = layui.admin;
        var dropdown = layui.dropdown;

        // 渲染回访表格
        var insTb = table.render({
            elem: '#tableTrack',
            url: "{:url('wechat/user/index_json',['subscribe'=>input('subscribe'),'subscribe_scene'=>input('subscribe_scene')])}",
            page: true,
            limit:10,
            limits:[10,30,50,100,200,500,1000],
            loading:true,
            //totalRow: true,
            cols: [[
                {type: 'numbers', title: '序号'},
                {align: 'center', templet: function (d) {
                        if(d.avatarurl){
                            return '<img src="' + d.avatarurl + '" class="tdImg" tb-img/>';
                        }else{
                            return '';
                        }
                    }, title: '头像', width: 90, unresize: true
                },
                {field: 'nickname', align: 'center', sort: true, title: '昵称', width: 180},
                {field: 'gender', align: 'center', sort: true, title: '性别', width: 140},
                {align: 'left', templet: function (d) {
                        return d.country + '/' + d.province + '/'+ d.city;
                    }, title: '区域', unresize: true
                },
                {field: 'subscribe_time', align: 'center', sort: true, title: '时间'},
                {field: 'openid', align: 'center', sort: true, title: 'OPENID'},
                {toolbar: '#demoEDStateBar1', sort: true, title: '状态', width: 160},
                {field: 'subscribe_scene', align: 'left', title: '来源'},
            ]],
            parseData: function(res){ //res 即为原始返回的数据
                console.log(res)
                return {
                  "code": res.code, //解析接口状态
                  "msg": res.msg, //解析提示文本
                  "count": res.data.total, //解析数据长度
                  "data": res.data.data //解析数据列表
                };
            }
        });
        
    });
</script>
{/block}